package com.cangsan.erhai.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cangsan.erhai.common.R;
import com.cangsan.erhai.entity.TabContest;
import com.cangsan.erhai.entity.TabContestMake;
import com.cangsan.erhai.service.TabContestMakeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/contestmake")
public class TabContestMakeController {
    @Autowired
    TabContestMakeService tabContestMakeService;

    @PostMapping("/saveOrUpdate")
    public R saveOrUpdate(@RequestBody TabContestMake tabContestMake){
        tabContestMakeService.saveOrUpdate(tabContestMake);
        return R.ok();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody TabContestMake tabContestMake){
        QueryWrapper<TabContestMake> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",tabContestMake.getUserId());
        queryWrapper.eq("tab_contest_id",tabContestMake.getTabContestId());
        tabContestMakeService.remove(queryWrapper);
        return R.ok();
    }


}
